package com.zyh.homework.test03;

import java.util.ArrayList;
import java.util.Scanner;

//java woaijava,i like jajavava i enjoy java
public class Test3 {
    public static void main(String[] args) {
        System.out.println("请输入源字符串：");
        String str = new Scanner(System.in).nextLine();
        System.out.println("请输入要删除的字符串：");
        String deleteStr = new Scanner(System.in).next();
        char[] chs = str.toCharArray();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i < chs.length; i++) {
            int num = str.indexOf("ja", i);
            arr.add(num);
            i = num;
            if (num < 0) {
                break;
            }
        }
        System.out.println("源字符串中总共包含" + (arr.size() - 1) + "个" + deleteStr);
        String replace = str.replace(deleteStr, " ");
        System.out.println("replace = " + replace);
    }
}
